﻿using System;
using System.Collections.Generic;
using BotonJXC.Entity;
using UnitDAO = BotonJXC.DAO.UnitDAO;
using BotonJXC.Util;
using NHibernate.Criterion;

namespace BotonJXC.BLL
{
    public class UnitBLL : BaseBLL<UnitDAO, Unit, int>
    {
        public UnitBLL()
        {
        }

        public IList<Unit> Find(int start, int count)
        {
            return Dao.Find(new ICriterion[]{}, null, start, count);
        }
        public PageModel<Unit> Find(string unitName, int start, int count)
        {
            List<ICriterion> criterions = new List<ICriterion>();
            if (!string.IsNullOrEmpty(unitName))
            {
                criterions.Add(Restrictions.Like("UnitName", unitName, MatchMode.Anywhere));
            }
            return Dao.FindByPage(criterions.ToArray(), null, start, count);
        }
    }
}
